//
//  DIVARequest.h
//  JigSawKiosk
//
//  Created by Stulberg on 10-10-20.
//  Copyright 2010 FruitonLabs. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#import <JSON/JSON.h>

@interface DIVARequest : NSObject {
	SBJsonParser *parser ;
	NSTimer *requestTimer ;
	
	NSThread *divaThread ;
	
	NSAutoreleasePool *pool ;
	NSRunLoop *runloop ;
	
	NSURLRequest *request ;
	NSMutableData *responseData;
	
	NSData *response ;
	
	NSString *requestString  ;
	
	NSRecursiveLock *fLock ;
	
	int fStatus;
    NSError* fError;
	
	id delegate ;
}

-(void) jsonRequest ;

-(void)requestTimerMethod:(NSTimer*) timer ;
-(void) startRequestTimer ;

-(void) newConnection ;

/* ---------------------------------
 Delagate methods
 ---------------------------------*/
- (void)setDelegate:(id)aDelegate ;
- (void)delegatedMethod ;
- (void) presentMethod ;
- (void) absentMethod ;

@property (nonatomic, retain) NSMutableData *responseData ;
@property (nonatomic, retain) NSString *requestString  ;

@end



/* ---------------------------------
 Delegate interface
 ---------------------------------*/
@interface NSObject(DIVARequestDelegateMethods)
- (void) divaRequestCallback:(DIVARequest *)myDIVARequest ;
- (void) divaPresentCallback:(DIVARequest *)myDIVARequest ;
- (void) divaAbsentCallback:(DIVARequest *)myDIVARequest ;
@end